<template>
  <div>
    <el-tabs v-model="active">
      <el-tab-pane label="组件属性" name="first">
        <el-row type="flex" align="middle">
          <el-col :span="6">
            <div class="prop-set-title">字段标识</div>
          </el-col>
          <el-col :span="18">
            <select-model :model.sync="store.current.model"></select-model>
          </el-col>
        </el-row>

        <el-row type="flex" align="middle">
          <el-col :span="6">
            <div class="prop-set-title">
              对齐方式
            </div>
          </el-col>
          <el-col :span="18">
            <el-select v-model="store.current.options.align" placeholder="请选择对齐方式">
              <el-option v-for="item in alignOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-col>
        </el-row>

        <el-row type="flex" align="middle">
          <el-col :span="6">
            <div class="prop-set-title">分栏间隔</div>
          </el-col>
          <el-col :span="18">
            <el-input
              @change="modelNameChange"
              v-model="store.current.options.gutter"
              placeholder="label"
            ></el-input>
          </el-col>
        </el-row>

        <el-row type="flex" align="middle">
          <el-col :span="6">
            <div class="prop-set-title">上边距</div>
          </el-col>
          <el-col :span="18">
            <el-slider v-model="store.current.options.marginTop"></el-slider>
          </el-col>
        </el-row>

        <el-row type="flex" align="middle">
          <el-col :span="6">
            <div class="prop-set-title">下边距</div>
          </el-col>
          <el-col :span="18">
            <el-slider v-model="store.current.options.marginBottom"></el-slider>
          </el-col>
        </el-row>

      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import clone from "clone";
export default {
  inject: ["getStore"],
  data() {
    return {
      active: "first",
      alignOptions: [{
        value: "center",
        label: '居中'
      }, {
        value: "left",
        label: '居左'
      }, {
        value: "right",
        label: '居右'
      }],
    };
  },
  watch: {
    "store.current.options": {
      handler() {
        //特别注意，不能用箭头函数，箭头函数，this指向全局
        this.$handleStack.push(clone(this.store.root));
      },
      // immediate: true,  //刷新加载 立马触发一次handler
      deep: true, // 可以深度检测到 obj 对象的属性值的变化
    },
  },
  computed: {
    store() {
      return this.getStore();
    },
  },
};
</script>

<style  scoped>
>>> .m-colorPicker .box {
  position: fixed !important;
}
>>> .el-tabs__nav{
  text-align: center;
}
</style>